<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>angular控制器</title>
    <script src="../../resources/src/js/angular.js"></script>
</head>
<body ng-app="myApp">
    <div ng-controller="myController1">
        a : <input type="number" ng-model="num1">
        <br>
        b : <input type="number" ng-model="num2">
        <br>
        a + b = {{count()}}
    </div>
</body>
<script>
    var myApp = angular.module("myApp",[]);
    //使用内联式的注入方式，而不是推断型
    myApp.controller("myController1",['$scope',function ($scope) {
        $scope.num1 = 0;
        $scope.num2 = 0;
        //scope里可以定义函数
        $scope.count = function () {
            return $scope.num1 + $scope.num2;
        }
    }]);
</script>
</html>